package com.wonderful.eyepetizer.data.di

import android.content.Context
import com.wonderful.eyepetizer.data.db.AppDatabase
import com.wonderful.eyepetizer.data.db.VideoDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
 * Desc: 数据库相关 module
 * @Author: wonderful
 * @Time: 2024/2/20 19:44
 */
@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {

    @Singleton
    @Provides
    fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase =
        AppDatabase.getDatabase(context)

    @Provides
    fun provideVideoDao(database: AppDatabase): VideoDao = database.videoDao()
}